<template>
  <div>
    <div class="logistics-info-header">
      <div class="logistics-info-header-left">
        <div
          class="logistics-status"
          :class="{ blue: info.logisticsStatus === 2 }"
        >
          {{
            { 0: '未发货', 1: '已发货', 2: '已签收', 3: '未签收' }[
              info.logisticsStatus
            ]
          }}
        </div>
        <div class="logistics-company">{{ info.logisticsCompany }}</div>
        <div class="logistics-no">{{ info.logisticsNo }}</div>
      </div>
    </div>
    <ul class="logistics-info-list">
      <li v-for="item in info.logisticsInfo" :key="item.time">
        <div class="logistics-info-list-time">{{ item.time }}</div>
        <div class="logistics-info-list-content">{{ item.content }}</div>
      </li>
    </ul>
    <button v-role="info.role">查看物流详情</button>
  </div>
</template>

<script>
export default {
  name: 'GoodsLog',
  props: {
    info: {
      type: Object,
      default: () => ({}),
    },
  },

  directives: {
    role: {
      inserted(el, { value }) {
        const res = ['admin', 'zhangsan', 'lisi'].includes(value)

        el.disabled = !res
      },
    },
  },
}
</script>

<style scoped>
.logistics-info-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.logistics-info-header-left {
  display: flex;
  align-items: center;
}

.logistics-status {
  font-weight: bold;
  font-size: 16px;
}

.blue {
  color: #007bff;
}

.logistics-company,
.logistics-no {
  margin-left: 10px;
  font-size: 14px;
  color: #333;
}

.logistics-info-list {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 230px;
  overflow-y: auto;
}

.logistics-info-list li {
  display: flex;
  margin-bottom: 10px;
}

.logistics-info-list-time {
  font-size: 12px;
  color: #999;
  width: 80px;
  text-align: right;
  margin-right: 10px;
}

.logistics-info-list-content {
  font-size: 14px;
  color: #333;
}
</style>
